home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intoids.lha / Intoids 1.0 / Developer / Docs / Intoids.doc next >
Text File  |  1997-02-13  |  42KB  |  1,117 lines

  1. TABLE OF CONTENTS
  2.  
  3. intoids.library/--background--
  4. intoids.library/--FileFormat--
  5. intoids.library/--UserCallBackStreamFunction--
  6. intoids.library/AbsoluteIntoid
  7. intoids.library/AddIntoids
  8. intoids.library/AsciiToIntoid
  9. intoids.library/CompareIntoidMagnitudes
  10. intoids.library/CompareIntoids
  11. intoids.library/CopyIntoid
  12. intoids.library/DivideIntoids
  13. intoids.library/FreeIntoid
  14. intoids.library/GetIntoidsMessage
  15. intoids.library/GetLastIntoidErrorMessage
  16. intoids.library/IntoidFitsInLong
  17. intoids.library/IntoidToAscii
  18. intoids.library/IntoidToLong
  19. intoids.library/IntoidToPortableIntViaBuffer
  20. intoids.library/IntoidToPortableIntViaCallBack
  21. intoids.library/LongToIntoid
  22. intoids.library/MultiplyIntoids
  23. intoids.library/NegateIntoid
  24. intoids.library/PortableIntLengthViaBuffer
  25. intoids.library/PortableIntLengthViaCallBack
  26. intoids.library/PortableIntSizeOfIntoid
  27. intoids.library/PortableIntToIntoidViaBuffer
  28. intoids.library/PortableIntToIntoidViaCallBack
  29. intoids.library/SignOfIntoid
  30. intoids.library/SmallIntToIntoid
  31. intoids.library/SubtractIntoids
  32. intoids.library/--background--                 intoids.library/--background--
  33.  
  34.    NAME
  35.        intoids.library -- Arbitrary precision integer math in 32 bits.
  36.  
  37.    FUNCTION
  38.        This set of subroutines lets other programs easily handle large
  39.        integer numbers.  It is a wrapper around the GNU Integer library
  40.        (which implements large integers as an array of shorts) that lets you
  41.        deal with all integers as 32 bit values (small integers are stored as
  42.        a shifted odd value and larger ones are stored as a pointer to a
  43.        variation of the GNU large integer).  It also supports special values
  44.        for infinity and not-a-number conditions.  Written to support large
  45.        sized files in the upcoming AGMS virtual file system.
  46.  
  47.    INPUTS
  48.        RecycleMe - most functions that return an Intoid also take a
  49.            parameter called RecycleMe.  Treat it as if it is used in a call
  50.            to the FreeIntoid function.  If RecycleMe isn't NULL then its
  51.            storage will be recycled to hold the result (or reallocated if it
  52.            is too small).  If RecycleMe is NULL then new memory will be
  53.            allocated for the function result.  If the function fails
  54.            (returns NULL) then the RecycleMe variable is deallocated.  This
  55.            is here mostly to reduce the number of memory allocations that
  56.            would otherwise be made.
  57.  
  58.    RESULT
  59.        Intoid values - all functions returning Intoids will return NULL if
  60.            out of memory or if the number is too big to be represented.
  61.            Some also return NULL for not-a-number error conditions (like
  62.            divide by zero).
  63.  
  64.    COPYRIGHT
  65.        Modifications for storing smaller integers in 32 bit values and
  66.        conversion to an Amiga library copyright (C) 1996 by Alexander G. M.
  67.        Smith.  Original long integer code copyright (C) 1988 Free Software
  68.        Foundation.
  69.  
  70.        This library is free software; you can redistribute it and/or modify
  71.        it under the terms of the GNU Library General Public License as
  72.        published by the Free Software Foundation; either version 2 of the
  73.        License, or (at your option) any later version.
  74.  
  75.        This library is distributed in the hope that it will be useful, but
  76.        WITHOUT ANY WARRANTY; without even the implied warranty of
  77.        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  78.        Library General Public License for more details.
  79.  
  80.        You should have received a copy of the GNU Library General Public
  81.        License along with this library; if not, write to the Free Software
  82.        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  83.  
  84.    AUTHOR
  85.        Modifications for the Amiga library and 32 bit storage implemented by
  86.        Alexander G. M. Smith, Ottawa Canada, agmsmith@achilles.net,
  87.        agmsmith@FreeNet.Carleton.ca, agmsmith@bix.com,
  88.        71330.3173@compuserve.com, and probably other places in the future.
  89.        Send mail to all these addresses to find ones which are still valid
  90.        (list made in November 1996).
  91.  
  92.        Original long integer code written by Doug Lea (dl@rocky.oswego.edu).
  93.        The GNU G++ library's Integer.cc file also has these attributions:
  94.        Some of the following algorithms are very loosely based on those from
  95.        MIT C-Scheme bignum.c, which is
  96.            Copyright (c) 1987 Massachusetts Institute of Technology
  97.        with other guidance from Knuth, vol. 2
  98.        Thanks to the creators of the algorithms.
  99.  
  100.    NOTES
  101.        To compile intoids.library, use the SAS C compiler, version 6.56.
  102.        Use 32 bit integers, 32 bit longs and 16 bit shorts.  Naturally, you
  103.        can use whatever compiler you want to write code for calling the
  104.        library (SASC and GNU are supported, and there is an .FD file for
  105.        making interfaces for other compilers).  Here's the SCOPTIONS file I
  106.        used for making intoids.library:
  107.            PARAMETERS=REGISTERS
  108.            NOSTACKCHECK
  109.            NOCHECKABORT
  110.            ERRORREXX
  111.            OPTIMIZE
  112.            LINK
  113.            LISTMACROS
  114.            LISTINCLUDES
  115.            STRINGSCONST
  116.            OPTIMIZERINLINELOCAL
  117.            VERBOSE
  118.            MAP
  119.            MAPHUNK
  120.            MAPSYMBOLS
  121.            MAPLIB
  122.            MAPXREFERENCE
  123.            STRICT
  124.            LIBRARYCODE
  125.            OPTIMIZERTIME
  126.            STRINGSECTION=CODE
  127.            STARTUP=libinit
  128.            PROGRAMNAME=intoids.library
  129.            MAPFILE=Intoids.map
  130.            PUBSCREEN=Workbench
  131.            LIBRARYFDFILE=Intoids.fd
  132.            LIBRARYVERSION=1
  133.            LIBRARYREVISION=0
  134.            OPTIMIZERCOMPLEXITY=1
  135.            OPTIMIZERDEPTH=1
  136.            OPTIMIZERRECURDEPTH=0
  137.  
  138.    BUGS
  139.        Not all the functions from the GNU Integer library were implemented.
  140.        If you want modulo, power and other functions, either ask me or do it
  141.        yourself.  It's a matter of cutting and pasting the code from GNU's
  142.        Integer.cc and fixing up a few things to handle Intoids rather than
  143.        IntReps.
  144.  
  145.    SEE ALSO
  146.        GNU's G++ library Integer.cc file for the original code and yet more
  147.        arbitrary precision functions.
  148.  
  149. intoids.library/--FileFormat--                 intoids.library/--FileFormat--
  150.  
  151.    NAME
  152.        AGMSPortableIntFormat -- Description of the Portable Integer Format.
  153.  
  154.    FUNCTION
  155.        This binary number format has to handle all values that could
  156.        be represented by an Intoid and has to be efficient in storage
  157.        space (so that the AGMS virtual file system databases aren't
  158.        too large).  It also has to be machine independant.
  159.  
  160.        To make things simpler for current computer architectures, it is
  161.        based on a variable quantity of 8 bit bytes (almost all computers can
  162.        pick out an 8 bit byte from their memory efficiently, few can handle
  163.        arbitrarily large bit aligned data nicely, particularly in the C
  164.        language).
  165.  
  166.        The general format is: FirstByte, optional size extension bytes,
  167.        optional data bytes.
  168.  
  169.        The size extension byte(s) are located just after FirstByte and just
  170.        before the actual data bytes.  If the first size extension byte is
  171.        255 (all 1 bits) then the size value is in two bytes after that
  172.        (least significant byte comes first), and if those are all 1 bits
  173.        then the size is in the following 4 bytes, and so on, doubling in
  174.        length if the previous size extension value is all 1 bits.  Don't
  175.        use an extension of zero, that can cause trouble with some code
  176.        (extensions of zero are used to signal errors in the Intoids code).
  177.  
  178.        The number of optional data bytes is defined by the FirstByte and
  179.        the optional size extension bytes.  Large integers are stored as a
  180.        positive magnitude (the sign is encoded in FirstByte) in the data
  181.        bytes.  The least significant byte comes first, followed by
  182.        increasingly more significant bytes.  This was done because it is
  183.        easier to shrink or expand from the end of an array rather than the
  184.        start of an array when a number gets smaller or larger.
  185.  
  186.        The first byte can either be a small integer value (so that things
  187.        like file name string lengths fit in a byte) or part of a larger
  188.        integer or a special code.  Some numbers can be represented in
  189.        several different ways, you should be able to read all varieties,
  190.        and preferably write the shortest one.  Here is the encoding for the
  191.        first byte:
  192.  
  193.        $0 to $7F:
  194.          A small positive integer with value 0 to 127 directly
  195.          corresponding to treating FirstByte as an 8 bit 2's complement
  196.          integer.
  197.  
  198.        $96 to $FF:
  199.          A small negative integer with value -106 to -1 directly
  200.          corresponding to treating FirstByte as an 8 bit 2's complement
  201.          integer.
  202.  
  203.        $80 to $87
  204.          A positive number with 1 to 8 bytes of data following the FirstByte.
  205.          The number of data bytes is (unsigned byte) FirstByte - $7F.  No
  206.          size extension bytes.
  207.  
  208.        $88 to $8F
  209.          A negative number with 1 to 8 bytes of data following the FirstByte.
  210.          The number of data bytes is (unsigned byte) FirstByte - $87.  No
  211.          size extension bytes.
  212.  
  213.        $90
  214.          A positive integer.  Has a size extension and a data section.  The
  215.          size extension specifies the number of bytes in the data section.
  216.  
  217.        $91
  218.          A negative integer.  Has a size extension and a data section.  The
  219.          size extension specifies the number of bytes in the data section.
  220.  
  221.        $92
  222.          Signals that an extended special code follows, the size extension
  223.          bytes specify the special code.  There is no data section.  Note
  224.          that we want to avoid a size extension of zero (causes trouble),
  225.          so the special codes start at 1.
  226.  
  227.        $93 to $95
  228.          A special code number.  The particular one is FirstByte - $92.
  229.          There is no data section or size extension.  The special codes are:
  230.            1:  Positive integer infinity.
  231.            2:  Negative integer infinity.
  232.            3:  Not a number.  The NULL pointer of numbers.  The quiet kind
  233.                of not-a-number (doesn't raise error conditions when used).
  234.            4:  Noisy variety of not-a-number.  Generates an error if used
  235.                in math?  Intoids don't support it.  Uses FirstByte $92
  236.                style encoding.
  237.            5+: Future use, uses FirstByte $92 style for encoding.
  238.  
  239.  
  240.    EXAMPLE
  241.        00
  242.          A positive integer with a value of zero.  No size extension or
  243.          data bytes.
  244.  
  245.        F6
  246.          A negative integer with a value of -10.  No size extension or
  247.          data bytes.
  248.  
  249.        80 C8
  250.          A positive integer with no size extension and 1 ($80 - $7F = 1)
  251.          data byte.  It has a value of +200.
  252.  
  253.        8B 00 CA 9A 3B
  254.          A negative integer with no size extension and 4 ($8B - $87 = 4)
  255.          data bytes.  It has a value of -$3B9ACA00 = -1000000000.
  256.  
  257.        90 12 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18
  258.          A positive integer with a size extension of $12 = 18, and 18 data
  259.          bytes.  It has a value of $181716151413121110090807060504030201.
  260.  
  261.        90 FF 23 01 (FF repeated 291 times)
  262.          A positive integer with a size extension of $123 = 291 (note the
  263.          first size extension byte is $FF which means see the next two
  264.          bytes ($23 $01) for the size extension).  The data section has
  265.          291 bytes of $FF each.  This is an integer with a value of
  266.          2^2328 - 1.
  267.  
  268.        93
  269.          Special code 1, meaning positive infinity.
  270.  
  271.        94
  272.          Special code 2, meaning negative infinity.
  273.  
  274.        95
  275.          This is special code 3, the code for a quiet not-a-number.
  276.  
  277.        92 04
  278.          Special code number 4, error signalling variety of not-a-number.
  279.  
  280.        92 FF 23 01
  281.          Special code number $123 = 291.  Currently not defined to mean
  282.          anything (future use).  No data section even though it has size
  283.          extension bytes.
  284.  
  285.        91 FF FF FF 78 56 34 12 01 02 03 [and 305419893 more bytes here]
  286.          This is a negative integer with $12345678 = 305419896 bytes of
  287.          number in the data section.  Note the way the size extension grew
  288.          to hold the size of $12345678.  Most current computers would have
  289.          trouble loading this 300 megabyte number into memory, let alone
  290.          multiplying it with another one.
  291.  
  292. intoids.library/--UserCallBackStreamFunction--/--UserCallBackStreamFunction--
  293.  
  294.    NAME
  295.        AGMSPortableIntStreamCallBack -- User defined function for stream IO.
  296.  
  297.    SYNOPSIS
  298.        LONG STACKCALL AGMSPortableIntStreamCallBack (
  299.          ULONG Operation, APTR Buffer, LONG Amount, APTR UserPntr );
  300.  
  301.    FUNCTION
  302.        A user defined callback function that is used for reading and writing
  303.        AGMS Portable Integer numbers from or to a stream.
  304.  
  305.    INPUTS
  306.        Operation - this argument specifies what your function should do:
  307.            0:  Read data.  Fill the buffer with Amount data bytes.  Your
  308.                function returns the amount read, which will be less than
  309.                the Amount requested if it fails (end of file etc).
  310.            1:  Seek.  Seek relative to the current stream postion by
  311.                Amount bytes.  Amount is negative for seeking backwards,
  312.                but PortableInt functions will never do that.  Returns
  313.                the position in the stream if known, or just zero when
  314.                it succeeds, returns -1 if it fails (seek past EOF or
  315.                before start of file, IO errors).  Return -2 if you don't
  316.                implement seek, and a bunch of reads will be used instead.
  317.            2:  Write data.  Write Amount bytes from the buffer to the
  318.                stream.  Returns the amount written, which  will be less
  319.                than the Amount requested if it fails (IO error etc).
  320.            N:  For other unsupported Operation values please return -2.
  321.        Buffer - points to a buffer where the read in data is saved or
  322.          the data to be written is obtained.
  323.        Amount - used to specify the number of bytes to
  324.          read, skip over, or write.
  325.        UserPntr - the same value as passed into the original
  326.          PortableInt function call.  Usually will be a file
  327.          handle or something similar.
  328.  
  329.    RESULT
  330.        ActualAmount - the function returns the number of bytes actually
  331.            read or written, or the absolute file position after a seek.
  332.  
  333.    NOTES
  334.        The callback function is called using the C language stack
  335.        based calling convention.  In SAS C this is specified with
  336.        the __stdargs keywords.
  337.  
  338.    BUGS
  339.        Returned seek position value only good for files up to 2G.
  340.  
  341.    SEE ALSO
  342.        PortIntCallBackOp enum in Intoids.h, STACKCALL macro in Intoids.h.
  343.  
  344. intoids.library/AbsoluteIntoid                 intoids.library/AbsoluteIntoid
  345.  
  346.    NAME
  347.        AbsoluteIntoid -- Computes absolute value of an Intoid.
  348.  
  349.    SYNOPSIS
  350.        NewIntoid = AbsoluteIntoid( IntegerA, RecycleMe )
  351.        D0                          D0        D1
  352.  
  353.        Intoid AbsoluteIntoid( Intoid, Intoid );
  354.  
  355.    FUNCTION
  356.        Computes the absolute value of an Intoid.
  357.  
  358.    INPUTS
  359.        IntegerA - the value you want to get the negative of.
  360.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  361.  
  362.    RESULT
  363.        NewIntoid - newly allocated Intoid containing a copy of IntegerA if
  364.            IntegerA was positive, or the negative of IntegerA if it was
  365.            originally negative (the negative of a negative is positive), or
  366.            NULL if out of memory.
  367.  
  368. intoids.library/AddIntoids                         intoids.library/AddIntoids
  369.  
  370.    NAME
  371.        AddIntoids -- Adds two Intoids.
  372.  
  373.    SYNOPSIS
  374.        NewIntoid = AddIntoids( IntegerA, IntegerB, RecycleMe )
  375.        D0                      D0        D1        A0
  376.  
  377.        Intoid AddIntoids( Intoid, Intoid, Intoid );
  378.  
  379.    FUNCTION
  380.        Adds two intoids and returns a new one with the sum.
  381.  
  382.    INPUTS
  383.        IntegerA - one value to be added.
  384.        IntegerB - the other value to be added.
  385.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  386.  
  387.    RESULT
  388.        NewIntoid - newly allocated Intoid with a value of (A + B), or NULL
  389.            if out of memory.
  390.  
  391. intoids.library/AsciiToIntoid                   intoids.library/AsciiToIntoid
  392.  
  393.    NAME
  394.        AsciiToIntoid -- Convert an ASCII string to an Intoid.
  395.  
  396.    SYNOPSIS
  397.        New = AsciiToIntoid( Buffer, NextCharacterPntrPntr, Base, RecycleMe )
  398.        D0                   A0      A1                     D0    D1
  399.  
  400.        Intoid AsciiToIntoid( STRPTR, char **, UWORD, Intoid );
  401.  
  402.    FUNCTION
  403.        Converts a string to a number using the given base, much like
  404.        the standard C function strtol.  It recognizes numbers consisting of
  405.        some leading space ((spaces or tabs) or international isspace() if
  406.        locale.library is available), an optional sign, an optional base
  407.        indicator if Base is zero, and finally a bunch of digits (which can
  408.        also be the special current language specific strings for infinity or
  409.        not-a-number).
  410.  
  411.    INPUTS
  412.        Buffer - points to a buffer containing the NUL terminated string to
  413.            be converted.
  414.        NextCharacterPntrPntr - points to a user's pointer variable, or NULL
  415.            if you don't want to use it.  The user's pointer variable will be
  416.            set to point to the character after the last one that was part of
  417.            the number (or set to NULL if a bad error happened).
  418.        Base - which number system to use.  Base can be from 2 to 36.  A Base
  419.            of 0 can be used for automatic base determination (if the number
  420.            starts with "0x" then it is treated as base 16, if it starts with
  421.            "0" then base 8 is used, otherwise it defaults to base 10).
  422.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  423.  
  424.    RESULT
  425.        New - a newly allocated Intoid with the integer equivalent to the
  426.              string in Buffer.  NULL if out of memory or some other error
  427.              happens (or if the string says not-a-number).
  428.        NextCharacterPntrPntr - sets user's pointer to just after the number.
  429.  
  430.    NOTES
  431.        The special strings for infinity and not-a-number are language
  432.        dependent.  If you read a file written in English on a French
  433.        computer, it won't understand the special infinity values.  Instead,
  434.        you should use the portable binary formatting functions.
  435.  
  436.    SEE ALSO
  437.        GetIntoidsMessage(), MSG_INTOIDS_NOT_A_NUMBER, MSG_INTOIDS_INFINITY.
  438.  
  439. intoids.library/CompareIntoidMagnitudesntoids.library/CompareIntoidMagnitudes
  440.  
  441.    NAME
  442.        CompareIntoidMagnitudes -- Comparison of absolute values.
  443.  
  444.    SYNOPSIS
  445.        Result = CompareIntoidMagnitudes( IntegerA, IntegerB )
  446.        D0                                D0        D1
  447.  
  448.        LONG CompareIntoidMagnitudes( Intoid, Intoid );
  449.  
  450.    FUNCTION
  451.        Compares the absolute values of two Intoids, more efficiently than
  452.        using a subtraction of absolute values.
  453.  
  454.    INPUTS
  455.        IntegerA - one input value.
  456.        IntegerB - the other input value.
  457.  
  458.    RESULT
  459.        Result - returns a long value that depends on the comparison:
  460.            -1 for abs(IntegerA) < abs(IntegerB),
  461.             0 for abs(IntegerA) == abs(IntegerB),
  462.            +1 for abs(IntegerA) > abs(IntegerB).
  463.  
  464.    SEE ALSO
  465.        SignOfIntoid(), CompareIntoids().
  466.  
  467. intoids.library/CompareIntoids                 intoids.library/CompareIntoids
  468.  
  469.    NAME
  470.        CompareIntoids -- Signed comparison of two Intoid values.
  471.  
  472.    SYNOPSIS
  473.        Result = CompareIntoids( IntegerA, IntegerB )
  474.        D0                       D0        D1
  475.  
  476.        LONG CompareIntoids( Intoid, Intoid );
  477.  
  478.    FUNCTION
  479.        Compares the size of two Intoids, more efficiently than using a
  480.        subtraction.
  481.  
  482.    INPUTS
  483.        IntegerA - one input value.
  484.        IntegerB - the other input value.
  485.  
  486.    RESULT
  487.        Result - returns a long value that depends on the comparison:
  488.            -1 for IntegerA < IntegerB,
  489.             0 for IntegerA == IntegerB,
  490.            +1 for IntegerA > IntegerB.
  491.  
  492.    SEE ALSO
  493.        SignOfIntoid(), CompareIntoidMagnitudes().
  494.  
  495. intoids.library/CopyIntoid                         intoids.library/CopyIntoid
  496.  
  497.    NAME
  498.        CopyIntoid -- Allocates a copy of an Intoid.
  499.  
  500.    SYNOPSIS
  501.        NewIntoid = CopyIntoid( IntegerA, RecycleMe )
  502.        D0                      D0        D1
  503.  
  504.        Intoid CopyIntoid( Intoid, Intoid );
  505.  
  506.    FUNCTION
  507.        Allocates memory (if needed) and fills it with a copy of IntegerA.
  508.  
  509.    INPUTS
  510.        IntegerA - the Integer value you want to copy.
  511.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  512.  
  513.    RESULT
  514.        NewIntoid - A copy of IntegerA or NULL if out of memory.
  515.  
  516. intoids.library/DivideIntoids                   intoids.library/DivideIntoids
  517.  
  518.    NAME
  519.        DivideIntoids -- Computes value of one Intoid divided by another.
  520.  
  521.    SYNOPSIS
  522.        NewIntoid = DivideIntoids( IntegerA, IntegerB, RecycleMe )
  523.        D0                         D0        D1        A0
  524.  
  525.        Intoid DivideIntoids( Intoid, Intoid, Intoid );
  526.  
  527.    FUNCTION
  528.        Does division, IntegerA / IntegerB.
  529.  
  530.    INPUTS
  531.        IntegerA - one input value.
  532.        IntegerB - the other input value.
  533.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  534.  
  535.    RESULT
  536.        NewIntoid - newly allocated Intoid containing the value of
  537.            (IntegerA / IntegerB), or NULL if out of memory or if
  538.            you divided by zero.
  539.  
  540. intoids.library/FreeIntoid                         intoids.library/FreeIntoid
  541.  
  542.    NAME
  543.        FreeIntoid -- Deallocates an Intoid.
  544.  
  545.    SYNOPSIS
  546.        FreeIntoid( RecycleMe )
  547.                    A0
  548.  
  549.        void FreeIntoid( Intoid );
  550.  
  551.    FUNCTION
  552.        Deallocates memory used by the given Intoid.  OK to pass in NULL.
  553.        Like regular pointers, you shouldn't use the value in RecycleMe any
  554.        more after calling this function.
  555.  
  556.    INPUTS
  557.        RecycleMe - a previously allocated Intoid or NULL.
  558.  
  559. intoids.library/GetIntoidsMessage           intoids.library/GetIntoidsMessage
  560.  
  561.    NAME
  562.        GetIntoidsMessage -- Convert a message number to a localised string.
  563.  
  564.    SYNOPSIS
  565.        YourString = GetIntoidsMessage( StringNumber )
  566.        D0                            D0
  567.  
  568.        STRPTR GetIntoidsMessage( IntoidStringNumbers );
  569.  
  570.    FUNCTION
  571.        Returns a pointer to a message which corresponds to the string
  572.        number, the particular string depends on the user's language
  573.        preferences.  The string is obtained from the Intoids.catalog
  574.        file if the user's language isn't English.
  575.  
  576.    INPUTS
  577.        StringNumber - an enum from 0 to MSG_INTOIDS_MAX-1 that identifies
  578.            the message you want the international string for.  If you ask
  579.            for a string that doesn't exist, you will get the string
  580.            for MSG_INTOIDS_UNKNOWN_MESSAGE.
  581.  
  582.    RESULT
  583.        YourString - a pointer to a read-only string which will be valid
  584.            for as long as intoids.library is open.
  585.  
  586.    SEE ALSO
  587.        locale.library - docs on how locale stuff works.
  588.        Intoids.h - the enum of all message numbers.
  589.  
  590. intoids.library/GetLastIntoidErrorMessageds.library/GetLastIntoidErrorMessage
  591.  
  592.    NAME
  593.        GetLastIntoidErrorMessage -- Returns the latest error message.
  594.  
  595.    SYNOPSIS
  596.        MyString = GetLastIntoidErrorMessage( )
  597.        D0
  598.  
  599.        STRPTR GetLastIntoidErrorMessage( VOID );
  600.  
  601.    FUNCTION
  602.        Returns a pointer to the last error message.  Maybe be incorrect if
  603.        you are using multitasking to cause errors (you get the global latest
  604.        error, not your latest error).  Also resets the error message to be
  605.        the copyright and credits for this library (you get that message if
  606.        there hasn't been an error since the last call to this function).
  607.  
  608.    RESULT
  609.        MyString - a pointer to a read only string in your favorite language.
  610.  
  611.    NOTES
  612.        The same message was displayed to the user in a system requester,
  613.        or maybe not if that feature is turned off by the user.
  614.  
  615. intoids.library/IntoidFitsInLong             intoids.library/IntoidFitsInLong
  616.  
  617.    NAME
  618.        IntoidFitsInLong -- Tests if an Intoid fits in a long int.
  619.  
  620.    SYNOPSIS
  621.        Boolean = IntoidFitsInLong( IntegerA )
  622.        D0                          D0
  623.  
  624.        BOOL IntoidFitsInLong( Intoid );
  625.  
  626.    FUNCTION
  627.        Tests if an Intoid can be represented by an ordinary 32 bit long int.
  628.  
  629.    INPUTS
  630.        IntegerA - any Intoid.
  631.  
  632.    RESULT
  633.        Boolean - TRUE if the Intoid can fit into a long integer.  Numbers
  634.            too big, infinities and not-a-number return FALSE.
  635.  
  636.    SEE ALSO
  637.        IntoidToLong().
  638.  
  639. intoids.library/IntoidToAscii                   intoids.library/IntoidToAscii
  640.  
  641.    NAME
  642.        IntoidToAscii -- Converts an Intoid into printable ASCII text.
  643.  
  644.    SYNOPSIS
  645.        RequiredLength = IntoidToAscii( IntegerA, Buffer, BufferLength, Base)
  646.        D0                              A0        A1      D0            D1
  647.  
  648.        LONG IntoidToAscii( Intoid, STRPTR, LONG, UWORD );
  649.  
  650.    FUNCTION
  651.        Converts the Intoid to a readable string number in the given base.
  652.        Also can output special strings for not-a-number and infinities, and
  653.        various error messages if something goes wrong during the conversion.
  654.  
  655.    INPUTS
  656.        IntegerA - any Intoid.
  657.        Buffer - points to a user provided buffer that will be filled with
  658.            the NUL terminated string ASCII text equivalent of IntegerA.
  659.            This variable can be NULL (useful if you just want an estimate of
  660.            how long the string would be).
  661.        BufferLength - how many bytes are in Buffer.  Can be zero.
  662.        Base - what number system to use for the conversion.  Can be from 2
  663.            to 36 (because it uses the 26 lower case letters and '0' to '9'
  664.            for the output digits).
  665.  
  666.    RESULT
  667.        RequiredLength - returns the number of characters plus one (for the
  668.            NUL at the end of the string) required to represent the number
  669.            (may be more than BufferLength).
  670.        Buffer - filled with the number, or with '*' characters if it isn't
  671.            big enough to hold the number.
  672.  
  673.    NOTES
  674.        Uses about 1K of the caller's stack space.
  675.  
  676.    BUGS
  677.        Numbers can only be converted if they are less than
  678.        MAX_INTOID_ASCII_DIGITS long.  This is because a reversed number is
  679.        built up in a buffer this big on the caller's stack (thus you need
  680.        about 1K of stack when calling this function).  If a number is too
  681.        big, you will get an error message instead of the number.
  682.  
  683. intoids.library/IntoidToLong                     intoids.library/IntoidToLong
  684.  
  685.    NAME
  686.        IntoidToLong -- Converts an Intoid into a long integer.
  687.  
  688.    SYNOPSIS
  689.        MyLong = IntoidToLong( IntegerA )
  690.        D0                     D0
  691.  
  692.        LONG IntoidToLong( Intoid );
  693.  
  694.    FUNCTION
  695.        Converts an Intoid into the closest long integer.
  696.  
  697.    INPUTS
  698.        IntegerA - any Intoid.
  699.  
  700.    RESULT
  701.        MyLong - an ordinary 32 bit long int equal to IntegerA in value, if
  702.            possible.  If IntegerA is too big or too small then you get the
  703.            largest (0x7FFFFFFF) or smallest (0x80000000) long possible.
  704.            Plus and minus infinity become largest and smallest longs
  705.            respectively.  Not-a-number becomes zero.
  706.  
  707.    SEE ALSO
  708.        IntoidFitsInLong().
  709.  
  710. intoids.library/IntoidToPortableIntViaBufferrary/IntoidToPortableIntViaBuffer
  711.  
  712.    NAME
  713.        IntoidToPortableIntViaBuffer -- Converts Intoid to portable int.
  714.  
  715.    SYNOPSIS
  716.        Success = IntoidToPortableIntViaBuffer
  717.                  ( AnIntoid, BytesWrittenPntr, Buffer, BufferSize )
  718.        D0          D0        A0                A1      D1
  719.  
  720.        BOOL IntoidToPortableIntViaBuffer( Intoid, ULONG *, APTR, ULONG );
  721.  
  722.    FUNCTION
  723.        Writes the AGMS Portable Integer binary format equivalent of the
  724.        Intoid (big integer) to a buffer.
  725.  
  726.    INPUTS
  727.        AnIntoid - the arbitrarily big integer to be converted.
  728.        BytesWrittenPntr - points to a ULONG that will be set to the number
  729.            of bytes written, specify NULL if you aren't using this feature.
  730.        Buffer - points to an area of memory where the portable integer will
  731.            be written to.
  732.        BufferSize - amount of space in the buffer.  Has to be at least
  733.            enough for the entire portable integer, or you get a partial
  734.            portable integer in the buffer and BytesWritten equal to
  735.            BufferSize.
  736.  
  737.    RESULT
  738.        Success - returns TRUE (1) if successful, FALSE (0) if it fails.
  739.        BytesWrittenPntr - the pointed to ULONG is set to the number of
  740.            bytes actually written.  If you have an IO error then this
  741.            will be less than the actual size (see PortableIntSizeOfIntoid())
  742.            for the number.
  743.  
  744.    SEE ALSO
  745.        PortableIntSizeOfIntoid(), IntoidToPortableIntViaCallBack().
  746.  
  747. intoids.library/IntoidToPortableIntViaCallBack/IntoidToPortableIntViaCallBack
  748.  
  749.    NAME
  750.        IntoidToPortableIntViaCallBack -- Converts Intoid to portable int.
  751.  
  752.    SYNOPSIS
  753.        Success = IntoidToPortableIntViaCallBack
  754.                 ( AnIntoid, BytesWrittenPntr, CallBack, UserPntr)
  755.        D0         D0        A0                D1        A1
  756.  
  757.        BOOL IntoidToPortableIntViaCallBack
  758.             ( Intoid, ULONG *, PortIntCallBackPntr, APTR );
  759.  
  760.    FUNCTION
  761.        Writes the AGMS Portable Integer binary format equivalent of the
  762.        Intoid to a stream using a callback function.  Also tests to see if
  763.        your compiler can handle 30 letter function names :-).
  764.  
  765.    INPUTS
  766.        AnIntoid - the Intoid big integer to be converted.
  767.        BytesWrittenPntr - points to a ULONG that will be set to the number
  768.            of bytes written, specify NULL if you aren't using this feature.
  769.        CallBack - a user provided function that handles the input
  770.            stream, see the intoids.library/AGMSPortableIntStreamCallBack
  771.            entry in these autodocs for details.
  772.        UserPntr - Any pointer sized value you want.  This value will be
  773.            passed to your callback function.  Typically used for file
  774.            handles.
  775.  
  776.    RESULT
  777.        Success - returns TRUE (1) if successful, FALSE (0) if it fails.
  778.        BytesWrittenPntr - the pointed to ULONG is set to the number of
  779.            bytes actually written.  If you have an IO error then this
  780.            will be less than the actual size (see PortableIntSizeOfIntoid())
  781.            for the number.
  782.  
  783.    SEE ALSO
  784.        PortableIntSizeOfIntoid(), IntoidToPortableIntViaBuffer(),
  785.        AGMSPortableIntStreamCallBack.
  786.  
  787. intoids.library/LongToIntoid                     intoids.library/LongToIntoid
  788.  
  789.    NAME
  790.        LongToIntoid -- Converts a long int to an Intoid.
  791.  
  792.    SYNOPSIS
  793.        NewIntoid = LongToIntoid( LongA, RecycleMe )
  794.        D0                        D0     A0
  795.  
  796.        Intoid LongToIntoid( LONG, Intoid );
  797.  
  798.    FUNCTION
  799.        Converts a 32 bit long int into an Intoid.
  800.  
  801.    INPUTS
  802.        LongA - the integer you want to convert.
  803.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  804.  
  805.    RESULT
  806.        NewIntoid - a newly allocated Intoid with value equal to LongA.  NULL
  807.            if out of memory.
  808.  
  809.    SEE ALSO
  810.        SmallIntToIntoid().
  811.  
  812. intoids.library/MultiplyIntoids               intoids.library/MultiplyIntoids
  813.  
  814.    NAME
  815.        MultiplyIntoids -- Computes value of one Intoid times another.
  816.  
  817.    SYNOPSIS
  818.        NewIntoid = MultiplyIntoids( IntegerA, IntegerB, RecycleMe )
  819.        D0                           D0        D1        A0
  820.  
  821.        Intoid MultiplyIntoids( Intoid, Intoid, Intoid );
  822.  
  823.    FUNCTION
  824.        Does multiplication, IntegerA * IntegerB.
  825.  
  826.    INPUTS
  827.        IntegerA - one input value.
  828.        IntegerB - the other input value.
  829.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  830.  
  831.    RESULT
  832.        NewIntoid - newly allocated Intoid containing the value of
  833.            (IntegerA * IntegerB), or NULL if out of memory.
  834.  
  835. intoids.library/NegateIntoid                     intoids.library/NegateIntoid
  836.  
  837.    NAME
  838.        NegateIntoid -- Returns the negative of an intoid.
  839.  
  840.    SYNOPSIS
  841.        NewIntoid = NegateIntoid( IntegerA, RecycleMe )
  842.        D0                        D0        D1
  843.  
  844.        Intoid NegateIntoid( Intoid, Intoid );
  845.  
  846.    FUNCTION
  847.        Computes (0 - IntegerA).
  848.  
  849.    INPUTS
  850.        IntegerA - the value you want to get the negative of.
  851.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  852.  
  853.    RESULT
  854.        NewIntoid - newly allocated Intoid containing (0 - IntegerA), or NULL
  855.            if out of memory.
  856.  
  857. intoids.library/PortableIntLengthViaBuffer.library/PortableIntLengthViaBuffer
  858.  
  859.    NAME
  860.        PortableIntLengthViaBuffer -- Gets byte size of portable integer.
  861.  
  862.    SYNOPSIS
  863.        Length = PortableIntLengthViaBuffer( Buffer, BufferSize )
  864.        D0                                   A0      D1
  865.  
  866.        ULONG PortableIntLengthViaBuffer( APTR, ULONG );
  867.  
  868.    FUNCTION
  869.        Finds the length in bytes of an AGMS Portable Integer in a buffer.
  870.  
  871.    INPUTS
  872.        Buffer - points to an area of memory containing the portable integer.
  873.        BufferSize - amount of data in the buffer.
  874.  
  875.    RESULT
  876.        Length - returns the length or zero if something went wrong (hit end
  877.            of buffer before number completed, unsupported number kind or bad
  878.            number format).  Length includes the header size.
  879.  
  880.    BUGS
  881.        Doesn't work for numbers that take more than 2 Gigabytes of storage
  882.        space (garbage results in that case - but then that would be a very
  883.        big number that nobody would ever use, well maybe we could return an
  884.        Intoid instead of a ULONG :-).
  885.  
  886.    SEE ALSO
  887.        PortableIntLengthViaCallBack().
  888.  
  889. intoids.library/PortableIntLengthViaCallBackrary/PortableIntLengthViaCallBack
  890.  
  891.    NAME
  892.        PortableIntLengthViaCallBack -- Gets byte size of portable integer.
  893.  
  894.    SYNOPSIS
  895.        Length = PortableIntLengthViaCallBack( CallBack, UserPntr )
  896.        D0                                     D0        D1
  897.  
  898.        ULONG PortableIntLengthViaCallBack( PortIntCallBackPntr, APTR );
  899.  
  900.    FUNCTION
  901.        Finds the length in bytes of an AGMS Portable Integer and skips
  902.        over it.
  903.  
  904.    INPUTS
  905.        CallBack - a user provided function that handles the input
  906.            stream, see the intoids.library/AGMSPortableIntStreamCallBack
  907.            entry in these autodocs for details.
  908.        UserPntr - Any pointer sized value you want.  This value will be
  909.            passed to your callback function.  Typically used for file
  910.            handles.
  911.  
  912.    RESULT
  913.        Length - returns the length or zero if something went wrong (read
  914.            error or unsupported number kind or bad number format, in which
  915.            case an unknown number of bytes will have been read).  Length
  916.            includes the header size.
  917.  
  918.    NOTES
  919.        As a side effect, it has read all the bytes in the number.  You can
  920.        use this function to skip over a number (it seeks past the number
  921.        contents for big numbers).
  922.  
  923.    BUGS
  924.        Doesn't work for numbers that take more than 2 Gigabytes of storage
  925.        space (garbage results in that case, and unpredictable number of
  926.        bytes read in that case too - but then that would be a very big
  927.        number that nobody would ever use, well except when trying to foil
  928.        nanotechnology based decryption systems :-).
  929.  
  930.    SEE ALSO
  931.        PortableIntLengthViaBuffer(), AGMSPortableIntStreamCallBack.
  932.  
  933. intoids.library/PortableIntSizeOfIntoidntoids.library/PortableIntSizeOfIntoid
  934.  
  935.    NAME
  936.        PortableIntSizeOfIntoid -- Find Intoid size in portable int format.
  937.  
  938.    SYNOPSIS
  939.        Length = PortableIntSizeOfIntoid( AnIntoid )
  940.        D0                                D0
  941.  
  942.        ULONG PortableIntSizeOfIntoid( Intoid );
  943.  
  944.    FUNCTION
  945.        Finds the byte size of an Intoid when expressed in AGMS Portable
  946.        Integer format.
  947.  
  948.    INPUTS
  949.        AnIntoid - the big integer you want to find the formatted size of.
  950.  
  951.    RESULT
  952.        Length - the number of bytes it would take for the AGMS Portable
  953.            Integer binary format equivalent of AnIntoid.
  954.  
  955. intoids.library/PortableIntToIntoidViaBufferrary/PortableIntToIntoidViaBuffer
  956.  
  957.    NAME
  958.        PortableIntToIntoidViaBuffer -- Converts portable int to Intoid.
  959.  
  960.    SYNOPSIS
  961.        NewIntoid = PortableIntToIntoidViaBuffer
  962.                    ( Buffer, BufferSize, AmountReadPntr, RecycleMe )
  963.        D0            A0      D0          A1              D1
  964.  
  965.        Intoid PortableIntToIntoidViaBuffer( APTR, ULONG, ULONG *, Intoid );
  966.  
  967.    FUNCTION
  968.        Reads an arbitrarily long integer in AGMS Portable Integer format
  969.        from a buffer and returns the Intoid equivalent.
  970.  
  971.    INPUTS
  972.        Buffer - points to an area of memory containing the portable integer.
  973.        BufferSize - amount of data in the buffer.  Has to be at least
  974.            enough for the entire portable integer, or you get NULL returned.
  975.        AmountReadPntr - points to a long variable where the number of bytes
  976.            read will be placed.  Set to NULL if you don't want to use this
  977.            feature.
  978.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  979.  
  980.    RESULT
  981.        NewIntoid - an Intoid equivalent to the number, or NULL if it fails,
  982.            also NULL if the number is not-a-number.
  983.        AmountReadPntr - pointed to variable is updated with the number of
  984.            bytes that were actually read, will be from zero to BufferSize.
  985.  
  986.    BUGS
  987.        Doesn't work with numbers over 2G in storage space, but they won't fit
  988.        in an Intoid anyways (128K bytes max in an Intoid) or even in most
  989.        system's memory.
  990.  
  991.    SEE ALSO
  992.        PortableIntToIntoidViaCallBack().
  993.  
  994. intoids.library/PortableIntToIntoidViaCallBack/PortableIntToIntoidViaCallBack
  995.  
  996.    NAME
  997.        PortableIntToIntoidViaCallBack -- Converts portable int to Intoid.
  998.  
  999.    SYNOPSIS
  1000.        NewIntoid = PortableIntToIntoidViaCallBack
  1001.                    ( CallBack, UserPntr, AmountReadPntr, RecycleMe )
  1002.        D0            A0        D0        A1              D1
  1003.  
  1004.        Intoid PortableIntToIntoidViaCallBack
  1005.               ( PortIntCallBackPntr, APTR, ULONG *, Intoid );
  1006.  
  1007.    FUNCTION
  1008.        Reads an arbitrarily long integer in AGMS Portable Integer format
  1009.        from some input stream and returns the result as an Intoid.
  1010.  
  1011.    INPUTS
  1012.        CallBack - a user provided function that handles the input
  1013.            stream, see the intoids.library/AGMSPortableIntStreamCallBack
  1014.            entry in these autodocs for details.
  1015.        UserPntr - Any pointer sized value you want.  This value will be
  1016.            passed to your callback function.  Typically used for file
  1017.            handles.
  1018.        AmountReadPntr - points to a long variable where the number of bytes
  1019.            read will be placed.  Set to NULL if you don't want to use this
  1020.            feature.
  1021.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  1022.  
  1023.    RESULT
  1024.        NewIntoid - an Intoid equivalent to the number, or NULL if it fails,
  1025.            also NULL if the number is not-a-number.
  1026.        AmountReadPntr - pointed to variable is updated with the number of
  1027.            bytes that were actually read.
  1028.  
  1029.    NOTES
  1030.        Advances the stream to just past the number, if it succeded.
  1031.  
  1032.    BUGS
  1033.        Doesn't work with numbers over 2G in storage space, but they won't fit
  1034.        in an Intoid anyways (128K bytes max in an Intoid).
  1035.  
  1036.    SEE ALSO
  1037.        PortableIntToIntoidViaBuffer(), AGMSPortableIntStreamCallBack.
  1038.  
  1039. intoids.library/SignOfIntoid                     intoids.library/SignOfIntoid
  1040.  
  1041.    NAME
  1042.        SignOfIntoid -- Returns -1, 0 or +1 depending on Intoid's sign.
  1043.  
  1044.    SYNOPSIS
  1045.        MySign = SignOfIntoid( IntegerA )
  1046.        D0                     D0
  1047.  
  1048.        LONG SignOfIntoid( Intoid );
  1049.  
  1050.    FUNCTION
  1051.        Fast way of finding the sign of any Intoid.
  1052.  
  1053.    INPUTS
  1054.        IntegerA - any Intoid you want to find the sign of.
  1055.  
  1056.    RESULT
  1057.        MySign - reflects the sign of IntegerA in a LONG value.  Returns -1
  1058.            for negative integers (includes negative infinity), 0 for zero
  1059.            and non-numbers, 1 for positive integers (and +infinity).
  1060.  
  1061.    SEE ALSO
  1062.        CompareIntoids(), CompareIntoidMagnitudes().
  1063.  
  1064. intoids.library/SmallIntToIntoid             intoids.library/SmallIntToIntoid
  1065.  
  1066.    NAME
  1067.        SmallIntToIntoid -- Macro to convert a small value int to an Intoid.
  1068.  
  1069.    SYNOPSIS
  1070.        MyIntoid = SmallIntToIntoid( ANumber )
  1071.  
  1072.        Intoid SmallIntToIntoid( int );
  1073.  
  1074.    FUNCTION
  1075.        Converts a short integer or char (unsigned or signed) to an Intoid.
  1076.        Will also work for long integers if they aren't larger than
  1077.        0x3FFFFFFF in absolute value.  Use LongToIntoid to properly handle
  1078.        larger longs.
  1079.  
  1080.    INPUTS
  1081.        ANumber - some signed or unsigned char, int or long.
  1082.  
  1083.    RESULT
  1084.        MyIntoid - the Intoid equivalent, as a small integer form Intoid.
  1085.            Never returns NULL since it doesn't do memory allocation.
  1086.  
  1087.    NOTES
  1088.        Only works for integers with absolute value of 0x3FFFFFFF or less.
  1089.        Defined in <libraries/Intoids.h>.
  1090.  
  1091.    SEE ALSO
  1092.        LongToIntoid().
  1093.  
  1094. intoids.library/SubtractIntoids               intoids.library/SubtractIntoids
  1095.  
  1096.    NAME
  1097.        SubtractIntoids -- Computes value of one Intoid minus another.
  1098.  
  1099.    SYNOPSIS
  1100.        NewIntoid = SubtractIntoids( IntegerA, IntegerB, RecycleMe )
  1101.        D0                           D0        D1        A0
  1102.  
  1103.        Intoid SubtractIntoids( Intoid, Intoid, Intoid );
  1104.  
  1105.    FUNCTION
  1106.        Does subtraction, IntegerA - IntegerB.
  1107.  
  1108.    INPUTS
  1109.        IntegerA - one input value.
  1110.        IntegerB - the other input value.
  1111.        RecycleMe - an old Intoid you want to deallocate, or NULL.
  1112.  
  1113.    RESULT
  1114.        NewIntoid - newly allocated Intoid containing the value of
  1115.            (IntegerA - IntegerB), or NULL if out of memory.
  1116.  
  1117.